package com.lbd99.data.lbd.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lbd99.data.lbd.service.StatisticService;
import com.lbd99.data.lbd.service.TUserService;
import com.lbd99.data.lbd.vo.SysAccount;
import com.lbd99.data.lbd.vo.TUser;
@Controller
@RequestMapping("statistic")
public class StatisticController {
	@Autowired
	private TUserService tUserService;
	
	@Autowired
	private StatisticService statisticService;
	
	@RequestMapping(value = "/statisticCount")
	@ResponseBody
	public Map<String, Object> statisticCount(HttpSession httpSession){
		//拼装map条件
		Map<String,Object> map=new HashMap<String,Object>();
		/*===================================================================================================*/
	     SysAccount sysAccount = (SysAccount)httpSession.getAttribute("SESSION_INFO_OBJECT");//获取当前登录的用户
	        if(sysAccount.getType()==1){//如果是普通管理员，用手机号查询出user信息
	        	TUser user = tUserService.selectByPhone(sysAccount.getTel());
	        	if(user!=null){
	        		//根据用户id查出该用户伞下的ID集合(包含自身)
	        		List<Integer> ids = tUserService.selectTreeIds(user.getId());
	        		if(ids!=null && ids.size()>0){
	        			map.put("ids",ids);
	        		}
	        	}
	        }
		 /*======================================================================================================*/
		return statisticService.statisticData(map);
	}

}
